
<?
	  include("/inc/header.html") {}
    ?>    
     
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="panel panel">       
                                                <div class="panel-body pan" style="height: 310px">                                                                          
                                                        <div class="form-body pal" >
                                                        	 <div>
                                                             <label for="inputUsername" class="col-md-3 control-label">中文名称 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="nameZh" type="text"class="form-control" onchange="pinYin(this.value)" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        
                                                            <div >
                                                                <label for="inputUsername" class="col-md-3 control-label">英文名称 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="nameEn" type="text" class="form-control"  value=""/>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                           
                                                            <div>
                                                             <label for="inputUsername" class="col-md-3 control-label">solr数据类型 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="solrType" type="text"  class="form-control" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                              <div>
                                                             <label for="inputUsername" class="col-md-3 control-label">字符类型<span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="fieldType" type="text"  class="form-control" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div>
                                                               <input id="id" type="hidden"  class="form-control" />
                                                             <div>
                                                             <label for="inputUsername" class="col-md-3 control-label">排序 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="sort" type="text"  class="form-control" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                </div>
                                            </div>
                                         </div></div>
                                  
    
  <script>
  
var index1 = window.parent.getlay();
 $("#id").val(index1);
 
function Page() {   
              
    	        if(isNaN($("#sort").val())){
                  alert("必须是数字");
                  return null;
                   }
    	        
    	        
    $.ajax({  
                type : "post",  
                url : "./Knowledgesave.do",  
                data : {"id":index1,"nameEn":$("#nameEn").val(),"nameZh":$("#nameZh").val(),"solrType":$("#solrType").val(),"sort":$("#sort").val(),"fieldType":$("#fieldType").val()},
                dataType : "json", 
                async:false,  
                success : function(data) { 
                     var index = parent.layer.getFrameIndex(window.name); 
            window.parent.get();
            parent.layer.msg('添加或编辑成功');
            parent.layer.close(index); 
                },
	            error : function(data) {
                   alert("请求失败");
		        }
            });

          
    }  
  $(function(){
	demo1();	
});  
   function demo1(){

    $.getJSON('./Knowledgeedit.do', {
        id: index1 //向服务端传的参数，此处只是演示
    }, function(res){
        //此处仅仅是为了演示变化的内容
      $("#nameEn").val(res[0].nameEn);
       $("#nameZh").val(res[0].nameZh);
        $("#solrType").val(res[0].solrType);
         $("#fieldType").val(res[0].fieldType);
         $("#sort").val(res[0].sort);
         
        
    });
};
// 判断不为空函数
	
	
	//汉字转拼音
  function pinYin(pinyinName){
		$.ajax({
			type : "post",
			url : "pinYin.do",
			data : {
				"pinYin" : pinyinName,
			},
			async : false,
			dataType : "json",
			success : function(data) {
				$("#nameEn").val(data);
				
			},
			error : function(data) {
				alert("请求失败");
			}
		})
		}
	
</script>


